<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="我提交的" name="first">
        <el-tabs v-model="activeName2" @tab-click="handleClick2" type="border-card">
          <el-tab-pane label="待处理" name="first2">
            <commoncard :tjdcl="tjdcl" v-if="activeName2=='first2'" :activeName="'first2'" :fun="getallspllist"
              :pagobj="pagobj"
            ></commoncard>
          </el-tab-pane>
          <el-tab-pane label="已完成" name="first3">
            <commoncard :tjdcl="tjdcl" v-if="activeName2=='first3'" :activeName="'first3'" :fun="getallspllist2"
              :pagobj="pagobj"
            ></commoncard>
          </el-tab-pane>
        </el-tabs>
      </el-tab-pane>
      <el-tab-pane label="我审批的" name="second">
        <el-tabs v-model="activeName3" @tab-click="handleClick3" type="border-card">
          <el-tab-pane label="待处理" name="second2">
            <commoncard :tjdcl="tjdcl" v-if="activeName3=='second2'" :activeName="'second2'" :fun="getallspllist3"
              :pagobj="pagobj"
            ></commoncard>
          </el-tab-pane>
          <el-tab-pane label="已完成" name="second3">
            <commoncard :tjdcl="tjdcl" v-if="activeName3=='second3'" :activeName="'second3'" :fun="getallspllist4"
              :pagobj="pagobj"
            ></commoncard>
          </el-tab-pane>
        </el-tabs>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import commoncard from '~/components/sptype/commoncard.vue';

export default {
  components: {
    commoncard,
  },
  data() {
    return {
      activeName: 'first',
      activeName2: 'first2',
      activeName3: 'second2',
      ts: this.newStore(),
      tjdcl: [],
      pagobj: {
        currentPage3: 1,
        pagesize: 9,
        total: 10,
      },
    };
  },
  created() {
    this.getallspllist();
  },
  methods: {
    handleClick(value) {
      console.log(value.name, '1');

      if (value.name == 'second') {
        this.activeName3 = 'second2';
        this.pagobj.currentPage3 = 1;
        this.getallspllist3();
      } else if (value.name == 'first') {
        this.activeName2 = 'first2';
        this.pagobj.currentPage3 = 1;
        this.getallspllist();
      }
    },
    handleClick2(value) {
      if (value.name == 'first2') {
        this.pagobj.currentPage3 = 1;
        this.getallspllist();
      } else if (value.name == 'first3') {
        this.pagobj.currentPage3 = 1;
        this.getallspllist2();
      }
    },
    handleClick3(value) {
      if (value.name == 'second2') {
        this.pagobj.currentPage3 = 1;
        this.getallspllist3();
      } else if (value.name == 'second3') {
        this.pagobj.currentPage3 = 1;
        this.getallspllist4();
      }
    },
    // 获取提交待处理列表
    getallspllist() {
      const req = {
        handle: '9000B8B8D347526960C5BAB1FB6894EFB2C5F6497939F0A364DB999BBBD87697C67B86E4BCAC0AA3',
        start: (this.pagobj.currentPage3 - 1) * this.pagobj.pagesize,
        limit: this.pagobj.pagesize,
      };
      this.spost(this.ts, '/mainservlet', req)
        .then((ts) => {
          console.log(ts.d);
          this.tjdcl = ts.d.data.operation1;
          this.pagobj.total = parseInt(ts.d.data.operation2[0].hash.allrs);
        });
    },
    // 获取提交已完成列表
    getallspllist2() {
      const req = {
        handle: '9000B8B8D347526960C5BAB1FB6894EFB2C5F6497939F0A350E6046D0D589337B9558C6AE5E9678B',
        start: (this.pagobj.currentPage3 - 1) * this.pagobj.pagesize,
        limit: this.pagobj.pagesize,
      };
      this.spost(this.ts, '/mainservlet', req)
        .then((ts) => {
          console.log(ts.d);
          this.tjdcl = ts.d.data.operation1;
          this.pagobj.total = parseInt(ts.d.data.operation2[0].hash.allrs);
        });
    },
    // 获取审批待处理列表
    getallspllist3() {
      const req = {
        handle: '9000B8B8D347526960C5BAB1FB6894EFDAA9E0F0A8692CC8EEBAA5844184BC51804F94D95BA43906',
        start: (this.pagobj.currentPage3 - 1) * this.pagobj.pagesize,
        limit: this.pagobj.pagesize,
      };
      this.spost(this.ts, '/mainservlet', req)
        .then((ts) => {
          console.log(ts.d);
          this.tjdcl = ts.d.data.operation1;
          this.pagobj.total = parseInt(ts.d.data.operation2[0].hash.allrs);
        });
    },
    // 获取审批已完成列表
    getallspllist4() {
      const req = {
        handle: '9000B8B8D347526960C5BAB1FB6894EFDAA9E0F0A8692CC8EEBAA5844184BC517046F804ED0A16D2',
        start: (this.pagobj.currentPage3 - 1) * this.pagobj.pagesize,
        limit: this.pagobj.pagesize,
      };
      this.spost(this.ts, '/mainservlet', req)
        .then((ts) => {
          console.log(ts.d);
          this.tjdcl = ts.d.data.operation1;
          this.pagobj.total = parseInt(ts.d.data.operation2[0].hash.allrs);
        });
    },

  },
};
</script>

<style>

</style>
